home *** CD-ROM | disk | FTP | other *** search
/ Cream of the Crop 26 / Cream of the Crop 26.iso / os2 / pvm34b3.zip / pvm34b3 / pvm3 / libfpvm / WIN32 / Pvmfconfig.c < prev    next >
C/C++ Source or Header  |  1997-07-22  |  1KB  |  74 lines

  1.  
  2. /* $Id: Pvmfconfig.c,v 1.1 1997/06/27 16:22:34 pvmsrc Exp $ */
  3.  
  4. #ifdef WIN32
  5. #include "..\..\include\pvm3.h"
  6. #include "..\..\src\pvmwin.h"
  7. #else 
  8. #include "pvm3.h"
  9. #endif
  10.  
  11. #include "pvm_consts.h"
  12. #include "../../src/bfunc.h"
  13.  
  14. void /*__stdcall*/ __fortran
  15. PVMFCONFIG
  16.     (nhostp,
  17.         narchp,arch_len,
  18.         tidp,
  19.         name_ptr,name_len,
  20.         arch_ptr,
  21.         speedp,
  22.         infop)
  23.  
  24.     int  *nhostp, *narchp, *tidp, *speedp, *infop;
  25.     char * name_ptr; int name_len;
  26.     char * arch_ptr; int arch_len;
  27. {
  28.     static struct pvmhostinfo *hip = 0;
  29.     static int nhost = 0;
  30.     static int narch = 0;
  31.     static int next = 0;
  32.  
  33.     int cc;
  34.     struct pvmhostinfo *hip2;
  35.  
  36. #ifndef WIN32
  37.     char *malloc();
  38. #endif
  39. /* if user sets nhostp to -1 then pvmfconfig() will be reset */
  40.  
  41.     if (hip && (*nhostp == -1)) {
  42.         free((char*)hip);
  43.         hip = 0;
  44.     }
  45.  
  46.     if (!hip) {
  47.         if ((cc = pvm_config(&nhost, &narch, &hip2)) < 0) {
  48.             *infop = cc;
  49.             return;
  50.         }
  51.         hip = (struct pvmhostinfo*)malloc(nhost * sizeof(struct pvmhostinfo));
  52.         BCOPY((char*)hip2, (char*)hip, nhost * sizeof(struct pvmhostinfo));
  53.         next = 0;
  54.     }
  55.  
  56.     if (next < nhost) {
  57.         *nhostp = nhost;
  58.         *narchp = narch;
  59.         *tidp = hip[next].hi_tid;
  60.         ctofstr(name_ptr, name_len, hip[next].hi_name);
  61.         ctofstr(arch_ptr, arch_len, hip[next].hi_arch);
  62.         *speedp = hip[next].hi_speed;
  63.         *infop = 1;
  64.         next++;
  65.  
  66.     }
  67.  
  68.     if (next == nhost) {
  69.         free((char*)hip);
  70.         hip = 0;
  71.     }
  72. }
  73.  
  74.